import 'package:flutter/material.dart';
import 'package:wanchong/app/store/search.dart';

import 'package:wanchong/path.dart';
import 'package:wanchong/utils/common.dart';

class Infosearch extends StatefulWidget {
  @override
  _KonwState createState() => _KonwState();
}

class _KonwState extends State<Infosearch> {
  //搜索控制器
  TextEditingController phoneController = TextEditingController();
  bool deleteShow = false;
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Color(0xFFFAFAFA),
      child: Scaffold(
        backgroundColor: Color(0x00000000),
        appBar: new PreferredSize(
          child: new Container(
            padding:
                new EdgeInsets.only(top: MediaQuery.of(context).padding.top),
            child: Row(
              children: <Widget>[
                Container(
                  width: 15.0,
                ),
                Expanded(
                  child: Container(
                    height: 35.0,
                    decoration: BoxDecoration(
                      color: Color(0xFFFAFAFA),
                      borderRadius: BorderRadius.circular(4.0),
                    ),
                    alignment: Alignment.centerLeft,
                    child: Stack(
                      children: <Widget>[
                        Container(
                          margin: EdgeInsets.only(right: 30.0, left: 5.0),
                          child: TextField(
                            textInputAction: TextInputAction.search, //搜索框键盘设置
                            controller: phoneController,
                            style: TextStyle(
                                color: Color(0xFF3C4450), fontSize: 14.0),
                            keyboardType: TextInputType.text,
                            decoration: InputDecoration(
                              contentPadding:
                                  const EdgeInsets.symmetric(vertical: 4.0),
                              border: InputBorder.none,
                              hintText: "请输入要搜索的内容",
                              counterText: "",
                              hintStyle: TextStyle(
                                  color: Color(0xFFDBDBDB), fontSize: 18.0),
                            ),

                            onChanged: (text) {
                              if (text.length > 0) {
                                setState(() {
                                  deleteShow = true;
                                });
                              }
                              if (text.length == 0) {
                                deleteShow = false;
                              }
                            },
                            onSubmitted: (text) {
                              //键盘确实搜索回调
                              print("你点我干嘛,你进来了吗");
                            },
                          ),
                        ),
                        Positioned(
                          right: 10.0,
                          top: 10.0,
                          child: GestureDetector(
                            onTap: () {
                              setState(() {
                                phoneController.text = '';
                                deleteShow = false;
                              });
                            },
                            child: deleteShow
                                ? Container(
                                    width: 15.0,
                                    height: 15.0,
                                    child: Image.asset(
                                      'assets/login/login_input_icon_delete.png',
                                      width: 12.0,
                                      height: 12.0,
                                      fit: BoxFit.cover,
                                    ),
                                  )
                                : Container(),
                          ),
                        ),
                      ],
                    ),
                  ), 
                ),
                GestureDetector(
                  onTap: (){
                     Navigator.pop(context);
                  },
                  child: Container(
                    margin: EdgeInsets.only(left: 5.0, right: 15.0),
                    alignment: Alignment.centerLeft,
                    color: Colors.white,
                    child: Text(
                      '取消',
                      style: TextStyle(
                        color: Color(0xFF647280),
                        fontSize: 15.0,
                      ),
                    ),
                  ),
                )
              ],
            ),
            decoration: new BoxDecoration(
              gradient: new LinearGradient(
                  colors: [Colors.white, Colors.white],
                  begin: const FractionalOffset(0.0, 0.0),
                  end: const FractionalOffset(1.0, 1.0),
                  stops: [0.0, 1.0],
                  tileMode: TileMode.clamp),
            ),
          ),
          preferredSize: new Size(MediaQuery.of(context).size.width, 50.0),
        ),
        body: Container(
          color: Colors.white,
          child: ListView(
            children: <Widget>[
              ExpansionTile(
                title: Text(
                  "饲养攻略",
                  style: TextStyle(
                    color: Color(0xFF3C4450),
                    fontSize: 14.0,
                    fontWeight: FontWeight.w700,
                  ),
                ),
                backgroundColor: Colors.white,
                initiallyExpanded: false, //默认是否展开
                children: <Widget>[
                  Container(
                      height: 50.0,
                      alignment: Alignment.centerLeft,
                      margin: EdgeInsets.only(left: 15.0, right: 15.0),
                      child: Row(
                        children: <Widget>[
                          Container(
                            child: Icon(
                              Icons.search,
                              color: Color(0xFF3C4450),
                              size: 20.0,
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin: EdgeInsets.only(left: 5.0),
                              child: Text(
                                '柯基幼年期',
                                style: TextStyle(
                                    fontSize: 14.0, color: Color(0xFF3C4450)),
                              ),
                            ),
                          ),
                          Container(
                            child: Text(
                              '约175个结果',
                              style: TextStyle(
                                  fontSize: 14.0, color: Color(0xFF647280)),
                            ),
                          )
                        ],
                      )),
                  Container(
                      height: 50.0,
                      alignment: Alignment.centerLeft,
                      margin: EdgeInsets.only(left: 15.0, right: 15.0),
                      child: Row(
                        children: <Widget>[
                          Container(
                            child: Icon(
                              Icons.search,
                              color: Color(0xFF3C4450),
                              size: 20.0,
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin: EdgeInsets.only(left: 5.0),
                              child: Text(
                                '柯基幼年期',
                                style: TextStyle(
                                    fontSize: 14.0, color: Color(0xFF3C4450)),
                              ),
                            ),
                          ),
                          Container(
                            child: Text(
                              '约175个结果',
                              style: TextStyle(
                                  fontSize: 14.0, color: Color(0xFF647280)),
                            ),
                          )
                        ],
                      )),
                  Container(
                      height: 50.0,
                      alignment: Alignment.centerLeft,
                      margin: EdgeInsets.only(left: 15.0, right: 15.0),
                      child: Row(
                        children: <Widget>[
                          Container(
                            child: Icon(
                              Icons.search,
                              color: Color(0xFF3C4450),
                              size: 20.0,
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin: EdgeInsets.only(left: 5.0),
                              child: Text(
                                '柯基幼年期',
                                style: TextStyle(
                                    fontSize: 14.0, color: Color(0xFF3C4450)),
                              ),
                            ),
                          ),
                          Container(
                            child: Text(
                              '约175个结果',
                              style: TextStyle(
                                  fontSize: 14.0, color: Color(0xFF647280)),
                            ),
                          )
                        ],
                      )),
                  Container(
                      height: 50.0,
                      alignment: Alignment.centerLeft,
                      margin: EdgeInsets.only(left: 15.0, right: 15.0),
                      child: Row(
                        children: <Widget>[
                          Container(
                            child: Icon(
                              Icons.search,
                              color: Color(0xFF3C4450),
                              size: 20.0,
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin: EdgeInsets.only(left: 5.0),
                              child: Text(
                                '柯基幼年期',
                                style: TextStyle(
                                    fontSize: 14.0, color: Color(0xFF3C4450)),
                              ),
                            ),
                          ),
                          Container(
                            child: Text(
                              '约175个结果',
                              style: TextStyle(
                                  fontSize: 14.0, color: Color(0xFF647280)),
                            ),
                          )
                        ],
                      )),
                  Container(
                      height: 50.0,
                      alignment: Alignment.centerLeft,
                      margin: EdgeInsets.only(left: 15.0, right: 15.0),
                      child: Row(
                        children: <Widget>[
                          Container(
                            child: Icon(
                              Icons.search,
                              color: Color(0xFF3C4450),
                              size: 20.0,
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin: EdgeInsets.only(left: 5.0),
                              child: Text(
                                '柯基幼年期',
                                style: TextStyle(
                                    fontSize: 14.0, color: Color(0xFF3C4450)),
                              ),
                            ),
                          ),
                          Container(
                            child: Text(
                              '约175个结果',
                              style: TextStyle(
                                  fontSize: 14.0, color: Color(0xFF647280)),
                            ),
                          )
                        ],
                      )),
                  Container(
                      height: 50.0,
                      alignment: Alignment.centerLeft,
                      margin: EdgeInsets.only(left: 15.0, right: 15.0),
                      child: Row(
                        children: <Widget>[
                          Container(
                            child: Icon(
                              Icons.search,
                              color: Color(0xFF3C4450),
                              size: 20.0,
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin: EdgeInsets.only(left: 5.0),
                              child: Text(
                                '柯基幼年期',
                                style: TextStyle(
                                    fontSize: 14.0, color: Color(0xFF3C4450)),
                              ),
                            ),
                          ),
                          Container(
                            child: Text(
                              '约175个结果',
                              style: TextStyle(
                                  fontSize: 14.0, color: Color(0xFF647280)),
                            ),
                          )
                        ],
                      )),
                  Container(
                      height: 50.0,
                      alignment: Alignment.centerLeft,
                      margin: EdgeInsets.only(left: 15.0, right: 15.0),
                      child: Row(
                        children: <Widget>[
                          Container(
                            child: Icon(
                              Icons.search,
                              color: Color(0xFF3C4450),
                              size: 20.0,
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin: EdgeInsets.only(left: 5.0),
                              child: Text(
                                '柯基幼年期',
                                style: TextStyle(
                                    fontSize: 14.0, color: Color(0xFF3C4450)),
                              ),
                            ),
                          ),
                          Container(
                            child: Text(
                              '约175个结果',
                              style: TextStyle(
                                  fontSize: 14.0, color: Color(0xFF647280)),
                            ),
                          )
                        ],
                      )),
                  Container(
                      height: 50.0,
                      alignment: Alignment.centerLeft,
                      margin: EdgeInsets.only(left: 15.0, right: 15.0),
                      child: Row(
                        children: <Widget>[
                          Container(
                            child: Icon(
                              Icons.search,
                              color: Color(0xFF3C4450),
                              size: 20.0,
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin: EdgeInsets.only(left: 5.0),
                              child: Text(
                                '柯基幼年期',
                                style: TextStyle(
                                    fontSize: 14.0, color: Color(0xFF3C4450)),
                              ),
                            ),
                          ),
                          Container(
                            child: Text(
                              '约175个结果',
                              style: TextStyle(
                                  fontSize: 14.0, color: Color(0xFF647280)),
                            ),
                          )
                        ],
                      )),
                  Container(
                      height: 50.0,
                      alignment: Alignment.centerLeft,
                      margin: EdgeInsets.only(left: 15.0, right: 15.0),
                      child: Row(
                        children: <Widget>[
                          Container(
                            child: Icon(
                              Icons.search,
                              color: Color(0xFF3C4450),
                              size: 20.0,
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin: EdgeInsets.only(left: 5.0),
                              child: Text(
                                '柯基幼年期',
                                style: TextStyle(
                                    fontSize: 14.0, color: Color(0xFF3C4450)),
                              ),
                            ),
                          ),
                          Container(
                            child: Text(
                              '约175个结果',
                              style: TextStyle(
                                  fontSize: 14.0, color: Color(0xFF647280)),
                            ),
                          )
                        ],
                      )),
                ],
              ),
              ExpansionTile(
                title: Text(
                  "知识问答",
                  style: TextStyle(
                    color: Color(0xFF3C4450),
                    fontSize: 14.0,
                    fontWeight: FontWeight.w700,
                  ),
                ),
                backgroundColor: Colors.white,
                initiallyExpanded: false, //默认是否展开
                children: <Widget>[
                  Container(
                      height: 50.0,
                      alignment: Alignment.centerLeft,
                      margin: EdgeInsets.only(left: 15.0, right: 15.0),
                      child: Row(
                        children: <Widget>[
                          Container(
                            child: Icon(
                              Icons.search,
                              color: Color(0xFF3C4450),
                              size: 20.0,
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin: EdgeInsets.only(left: 5.0),
                              child: Text(
                                '柯基幼年期',
                                style: TextStyle(
                                    fontSize: 14.0, color: Color(0xFF3C4450)),
                              ),
                            ),
                          ),
                          Container(
                            child: Text(
                              '约175个结果',
                              style: TextStyle(
                                  fontSize: 14.0, color: Color(0xFF647280)),
                            ),
                          )
                        ],
                      )),
                ],
              ),
              ExpansionTile(
                title: Text(
                  "顽宠视频",
                  style: TextStyle(
                    color: Color(0xFF3C4450),
                    fontSize: 14.0,
                    fontWeight: FontWeight.w700,
                  ),
                ),
                backgroundColor: Colors.white,
                initiallyExpanded: false, //默认是否展开
                children: <Widget>[
                  Container(
                      height: 50.0,
                      alignment: Alignment.centerLeft,
                      margin: EdgeInsets.only(left: 15.0, right: 15.0),
                      child: Row(
                        children: <Widget>[
                          Container(
                            child: Icon(
                              Icons.search,
                              color: Color(0xFF3C4450),
                              size: 20.0,
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin: EdgeInsets.only(left: 5.0),
                              child: Text(
                                '柯基幼年期',
                                style: TextStyle(
                                    fontSize: 14.0, color: Color(0xFF3C4450)),
                              ),
                            ),
                          ),
                          Container(
                            child: Text(
                              '约175个结果',
                              style: TextStyle(
                                  fontSize: 14.0, color: Color(0xFF647280)),
                            ),
                          )
                        ],
                      )),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}
